package com.csyaonie.android.jump;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.csyaonie.android.R;

public class BActivity extends AppCompatActivity {

    private TextView tv_title;

    private Button bt_finish;
    private Button bt_back;

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        Log.d("BActivity","onNewIntent start");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_b);
        tv_title=findViewById(R.id.tv_title);
        bt_finish=findViewById(R.id.bt_finish);
        bt_back=findViewById(R.id.bt_back);
        Bundle bundle=getIntent().getExtras();
        tv_title.setText(bundle.getString("name")+":"+bundle.getInt("age"));

        Log.d("BActivity","taskId:"+getTaskId());
        Log.d("BActivity","hashCode:"+hashCode());

        bt_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(BActivity.this,AActivity.class);
                startActivity(intent);
            }
        });
        bt_finish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                Bundle bundle1=new Bundle();
                bundle1.putString("result","Iam Coming");
                intent.putExtras(bundle1);
                setResult(Activity.RESULT_OK,intent);
                finish();
            }
        });
    }
}